package view;

/**
 * @author eversonpaulo
 */
//import Relatorio.rel_Tabelas;
import Utilitarios.TamanhoMaximoTextField;
import dao.ProcessoDAO;

import java.awt.Component;
import java.awt.Cursor;
import java.awt.Font;

import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.GregorianCalendar;
import java.util.List;
import java.util.Locale;
import java.util.TimeZone;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.swing.plaf.basic.BasicInternalFrameUI;
import javax.swing.table.DefaultTableModel;
import model.Processo;

//import net.sf.jasperreports.engine.JRException;
public class framePesquisarProcesso extends javax.swing.JInternalFrame {

    private DefaultTableModel modelo = new DefaultTableModel() {
        public boolean isCellEditable(int row, int column) {
            return false;
        }
    };
    private DefaultTableModel modeloCOD = new DefaultTableModel() {
        public boolean isCellEditable(int row, int column) {
            return false;
        }
    };
    private DefaultTableModel modeloInteresse = new DefaultTableModel() {
        public boolean isCellEditable(int row, int column) {
            return false;
        }
    };
    private DefaultTableModel modeloData = new DefaultTableModel() {
        public boolean isCellEditable(int row, int column) {
            return false;
        }
    };
    private DefaultTableModel modeloAssunto = new DefaultTableModel() {
        public boolean isCellEditable(int row, int column) {
            return false;
        }
    };
    String opcao = "";
    public int inutil;

    public framePesquisarProcesso() {
        initComponents();

//        tabelaAssunto();
//      tabelaCod();
//       tabelaInterrese();
        exibePainel();
        jPanelPadrao.setVisible(true);
        jPanelNumero.setVisible(false);
        jPanelData.setVisible(false);
        jPanelAssunto.setVisible(false);
        jPanelMesano.setVisible(false);
        jPanelInteressado1.setVisible(false);
        tabelaGERAL();
        monta_jTPRocessoGERAL();

        //tabelaAssunto();
        //Tira as barras de todos os lados da janela
        ((BasicInternalFrameUI) this.getUI()).setNorthPane(null);
        ((BasicInternalFrameUI) this.getUI()).setSouthPane(null);
        ((BasicInternalFrameUI) this.getUI()).setWestPane(null);
        ((BasicInternalFrameUI) this.getUI()).setEastPane(null);

        lbCodigo.setFont(new Font("Tahoma", Font.PLAIN, 11));

        lbCodigo.setFont(new Font("Tahoma", Font.PLAIN, 11));

        int linhaAtual;
        linhaAtual = jTUnidade.getRowCount();
        if (linhaAtual > 0) {
            jTUnidade.changeSelection(0, 0, false, false);

        }

    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        jPanel2 = new javax.swing.JPanel();
        buttonGroup2 = new javax.swing.ButtonGroup();
        btPrimeiro = new javax.swing.JButton();
        btAnterior = new javax.swing.JButton();
        btProximo = new javax.swing.JButton();
        btUltimo = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTUnidade = new javax.swing.JTable();
        jPanel1 = new javax.swing.JPanel();
        jPanel4 = new javax.swing.JPanel();
        jRNumero = new javax.swing.JRadioButton();
        jRData = new javax.swing.JRadioButton();
        jRMesano = new javax.swing.JRadioButton();
        jRInteressado = new javax.swing.JRadioButton();
        jRAssunto = new javax.swing.JRadioButton();
        jLabel6 = new javax.swing.JLabel();
        jPanelData = new javax.swing.JPanel();
        lbCodigo1 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jtData1 = new com.toedter.calendar.JDateChooser();
        jButton1 = new javax.swing.JButton();
        jPanelNumero = new javax.swing.JPanel();
        jTnumeroProcesso = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        jPanelMesano = new javax.swing.JPanel();
        lbCodigo4 = new javax.swing.JLabel();
        cbMes2 = new javax.swing.JComboBox();
        jLabel4 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jTano1 = new javax.swing.JFormattedTextField();
        jPanelInteressado1 = new javax.swing.JPanel();
        lbCodigo5 = new javax.swing.JLabel();
        jtInteressado1 = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        jPanelAssunto = new javax.swing.JPanel();
        lbCodigo3 = new javax.swing.JLabel();
        jtAssunto1 = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        jPanelPadrao = new javax.swing.JPanel();
        jtCodSetor = new javax.swing.JTextField();
        lbCodigo = new javax.swing.JLabel();
        btSair = new javax.swing.JButton();

        setClosable(true);
        setTitle("Gerenciamento de Assunto");
        setToolTipText("");
        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        btPrimeiro.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/1398710613_playback_ff (2).png"))); // NOI18N
        btPrimeiro.setToolTipText("Primeiro Registro");
        btPrimeiro.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btPrimeiroActionPerformed(evt);
            }
        });
        getContentPane().add(btPrimeiro, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 540, -1, -1));

        btAnterior.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/1398710631_playback_play (2).png"))); // NOI18N
        btAnterior.setToolTipText("Registro Anterior");
        btAnterior.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btAnteriorActionPerformed(evt);
            }
        });
        getContentPane().add(btAnterior, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 540, -1, -1));

        btProximo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/1398710631_playback_play.png"))); // NOI18N
        btProximo.setToolTipText("Próximo Registro");
        btProximo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btProximoActionPerformed(evt);
            }
        });
        getContentPane().add(btProximo, new org.netbeans.lib.awtextra.AbsoluteConstraints(620, 540, -1, -1));

        btUltimo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/1398710613_playback_ff.png"))); // NOI18N
        btUltimo.setToolTipText("Último Registro");
        btUltimo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btUltimoActionPerformed(evt);
            }
        });
        getContentPane().add(btUltimo, new org.netbeans.lib.awtextra.AbsoluteConstraints(670, 540, -1, -1));

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        jLabel1.setText("Pesquisar Processo");
        getContentPane().add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 10, 690, 30));

        jTUnidade.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {},
                {},
                {},
                {}
            },
            new String [] {

            }
        ));
        jTUnidade.setToolTipText("Registro Cadastrados");
        jTUnidade.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTUnidadeMouseClicked(evt);
            }
        });
        jTUnidade.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jTUnidadeKeyReleased(evt);
            }
        });
        jScrollPane1.setViewportView(jTUnidade);

        getContentPane().add(jScrollPane1, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 190, 660, 340));
        getContentPane().add(jPanel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 650, 740, 10));
        getContentPane().add(jPanel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 20, 20, 550));

        buttonGroup1.add(jRNumero);
        jRNumero.setText("Número");
        jRNumero.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jRNumeroMouseClicked(evt);
            }
        });
        jRNumero.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRNumeroActionPerformed(evt);
            }
        });
        getContentPane().add(jRNumero, new org.netbeans.lib.awtextra.AbsoluteConstraints(150, 60, -1, -1));

        buttonGroup1.add(jRData);
        jRData.setText("Data");
        jRData.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRDataActionPerformed(evt);
            }
        });
        getContentPane().add(jRData, new org.netbeans.lib.awtextra.AbsoluteConstraints(250, 60, -1, -1));

        buttonGroup1.add(jRMesano);
        jRMesano.setText("Mês / Ano");
        jRMesano.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRMesanoActionPerformed(evt);
            }
        });
        getContentPane().add(jRMesano, new org.netbeans.lib.awtextra.AbsoluteConstraints(320, 60, -1, -1));

        buttonGroup1.add(jRInteressado);
        jRInteressado.setText("Interresado");
        jRInteressado.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRInteressadoActionPerformed(evt);
            }
        });
        getContentPane().add(jRInteressado, new org.netbeans.lib.awtextra.AbsoluteConstraints(420, 60, -1, -1));

        buttonGroup1.add(jRAssunto);
        jRAssunto.setText("Assunto");
        jRAssunto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRAssuntoActionPerformed(evt);
            }
        });
        getContentPane().add(jRAssunto, new org.netbeans.lib.awtextra.AbsoluteConstraints(530, 60, -1, -1));

        jLabel6.setText("Pesquisar Por:");
        getContentPane().add(jLabel6, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 60, -1, 20));

        jPanelData.setBorder(javax.swing.BorderFactory.createTitledBorder("Pesquisando por Data"));
        jPanelData.setToolTipText("Pesquisar");
        jPanelData.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        lbCodigo1.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        lbCodigo1.setText("Código :");
        lbCodigo1.setFocusable(false);
        jPanelData.add(lbCodigo1, new org.netbeans.lib.awtextra.AbsoluteConstraints(670, 130, 50, 20));

        jLabel7.setText("Data:");
        jPanelData.add(jLabel7, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 30, 40, 20));

        jtData1.addContainerListener(new java.awt.event.ContainerAdapter() {
            public void componentAdded(java.awt.event.ContainerEvent evt) {
                jtData1ComponentAdded(evt);
            }
        });
        jtData1.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jtData1FocusLost(evt);
            }
        });
        jtData1.addInputMethodListener(new java.awt.event.InputMethodListener() {
            public void caretPositionChanged(java.awt.event.InputMethodEvent evt) {
            }
            public void inputMethodTextChanged(java.awt.event.InputMethodEvent evt) {
                jtData1InputMethodTextChanged(evt);
            }
        });
        jtData1.addAncestorListener(new javax.swing.event.AncestorListener() {
            public void ancestorMoved(javax.swing.event.AncestorEvent evt) {
            }
            public void ancestorAdded(javax.swing.event.AncestorEvent evt) {
                jtData1AncestorAdded(evt);
            }
            public void ancestorRemoved(javax.swing.event.AncestorEvent evt) {
            }
        });
        jtData1.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jtData1KeyReleased(evt);
            }
        });
        jPanelData.add(jtData1, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 30, 140, -1));

        jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/1400784436_search_magnifying_glass_find.png"))); // NOI18N
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
        jPanelData.add(jButton1, new org.netbeans.lib.awtextra.AbsoluteConstraints(270, 30, 30, 25));

        getContentPane().add(jPanelData, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 100, 660, 80));

        jPanelNumero.setBorder(javax.swing.BorderFactory.createTitledBorder("Pesquisando por Número"));
        jPanelNumero.setToolTipText("Pesquisar");
        jPanelNumero.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jTnumeroProcesso.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTnumeroProcessoActionPerformed(evt);
            }
        });
        jTnumeroProcesso.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTnumeroProcessoFocusLost(evt);
            }
        });
        jTnumeroProcesso.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jTnumeroProcessoKeyReleased(evt);
            }
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jTnumeroProcessoKeyTyped(evt);
            }
        });
        jPanelNumero.add(jTnumeroProcesso, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 30, 200, -1));

        jLabel5.setText("Número:");
        jPanelNumero.add(jLabel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 30, 50, 20));

        getContentPane().add(jPanelNumero, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 100, 660, 80));

        jPanelMesano.setBorder(javax.swing.BorderFactory.createTitledBorder("Pesquisando por Mês / Ano"));
        jPanelMesano.setToolTipText("Pesquisar");
        jPanelMesano.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        lbCodigo4.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        lbCodigo4.setText("Código :");
        lbCodigo4.setFocusable(false);
        jPanelMesano.add(lbCodigo4, new org.netbeans.lib.awtextra.AbsoluteConstraints(670, 130, 50, 20));

        cbMes2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro \t" }));
        cbMes2.setSelectedIndex(-1);
        cbMes2.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                cbMes2KeyReleased(evt);
            }
        });
        jPanelMesano.add(cbMes2, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 30, 160, -1));

        jLabel4.setText("Mês:");
        jPanelMesano.add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 30, 40, 20));

        jLabel10.setText("Ano:");
        jPanelMesano.add(jLabel10, new org.netbeans.lib.awtextra.AbsoluteConstraints(350, 30, 40, 20));

        try {
            jTano1.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        jTano1.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        jTano1.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jTano1KeyReleased(evt);
            }
        });
        jPanelMesano.add(jTano1, new org.netbeans.lib.awtextra.AbsoluteConstraints(380, 30, 110, -1));

        getContentPane().add(jPanelMesano, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 100, 660, 80));

        jPanelInteressado1.setBorder(javax.swing.BorderFactory.createTitledBorder("Pesquisando por Interresado"));
        jPanelInteressado1.setToolTipText("Pesquisar");
        jPanelInteressado1.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        lbCodigo5.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        lbCodigo5.setText("Código :");
        lbCodigo5.setFocusable(false);
        jPanelInteressado1.add(lbCodigo5, new org.netbeans.lib.awtextra.AbsoluteConstraints(670, 130, 50, 20));

        jtInteressado1.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        jtInteressado1.setToolTipText("Sigla Do Organograma");
        jtInteressado1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtInteressado1ActionPerformed(evt);
            }
        });
        jtInteressado1.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jtInteressado1FocusLost(evt);
            }
        });
        jtInteressado1.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jtInteressado1KeyReleased(evt);
            }
        });
        jPanelInteressado1.add(jtInteressado1, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 30, 200, -1));

        jLabel9.setText("Interressado:");
        jPanelInteressado1.add(jLabel9, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 30, 80, 20));

        getContentPane().add(jPanelInteressado1, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 100, 660, 80));

        jPanelAssunto.setBorder(javax.swing.BorderFactory.createTitledBorder("Pesquisando por Assunto"));
        jPanelAssunto.setToolTipText("Pesquisar");
        jPanelAssunto.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        lbCodigo3.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        lbCodigo3.setText("Código :");
        lbCodigo3.setFocusable(false);
        jPanelAssunto.add(lbCodigo3, new org.netbeans.lib.awtextra.AbsoluteConstraints(670, 130, 50, 20));

        jtAssunto1.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        jtAssunto1.setToolTipText("Descrição do Setor");
        jtAssunto1.setAutoscrolls(false);
        jtAssunto1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtAssunto1ActionPerformed(evt);
            }
        });
        jtAssunto1.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jtAssunto1FocusLost(evt);
            }
        });
        jtAssunto1.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jtAssunto1KeyReleased(evt);
            }
        });
        jPanelAssunto.add(jtAssunto1, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 30, 200, -1));

        jLabel8.setText("Assunto:");
        jPanelAssunto.add(jLabel8, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 30, 60, 20));

        getContentPane().add(jPanelAssunto, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 100, 660, 80));

        jPanelPadrao.setBorder(javax.swing.BorderFactory.createTitledBorder(""));
        jPanelPadrao.setToolTipText("Pesquisar");
        jPanelPadrao.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jtCodSetor.setEditable(false);
        jtCodSetor.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jtCodSetor.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        jtCodSetor.setToolTipText("Código do Setor");
        jtCodSetor.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        jtCodSetor.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtCodSetorActionPerformed(evt);
            }
        });
        jPanelPadrao.add(jtCodSetor, new org.netbeans.lib.awtextra.AbsoluteConstraints(670, 150, 60, -1));

        lbCodigo.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        lbCodigo.setText("Código :");
        lbCodigo.setFocusable(false);
        jPanelPadrao.add(lbCodigo, new org.netbeans.lib.awtextra.AbsoluteConstraints(670, 130, 50, 20));

        getContentPane().add(jPanelPadrao, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 100, 660, 80));

        btSair.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/logout_user_login_account-3222.png"))); // NOI18N
        btSair.setToolTipText("Fechar o Cadastro das Unidade Métrica");
        btSair.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btSairActionPerformed(evt);
            }
        });
        getContentPane().add(btSair, new org.netbeans.lib.awtextra.AbsoluteConstraints(660, 600, -1, -1));
        btSair.getAccessibleContext().setAccessibleDescription("Fechar ");

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btPrimeiroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btPrimeiroActionPerformed
        int linhaAtual;
        linhaAtual = jTUnidade.getRowCount();
        if (linhaAtual > 0) {
            jTUnidade.changeSelection(0, 0, false, false);

        }

        btProximo.setEnabled(true);
        btUltimo.setEnabled(true);
        btPrimeiro.setEnabled(false);
        btAnterior.setEnabled(false);
    }//GEN-LAST:event_btPrimeiroActionPerformed

    private void btAnteriorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btAnteriorActionPerformed
        int linhaAtual;
        linhaAtual = jTUnidade.getSelectedRow() - 1;
        if (linhaAtual > 0) {
            jTUnidade.changeSelection(linhaAtual, linhaAtual, false, false);

        }

        if ((linhaAtual - 1) < 0) {
            btPrimeiro.setEnabled(false);
            btAnterior.setEnabled(false);
        } else {
            btProximo.setEnabled(true);
            btUltimo.setEnabled(true);
        }
    }//GEN-LAST:event_btAnteriorActionPerformed

    private void btProximoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btProximoActionPerformed
        int linhaAtual, qdeLinhas;
        linhaAtual = jTUnidade.getSelectedRow() + 1;
        qdeLinhas = jTUnidade.getRowCount();

        if (linhaAtual > 0) {
            jTUnidade.changeSelection(linhaAtual, linhaAtual, false, false);

        }

        if ((linhaAtual + 1) == qdeLinhas) {
            btProximo.setEnabled(false);
            btUltimo.setEnabled(false);
        } else {
            btPrimeiro.setEnabled(true);
            btAnterior.setEnabled(true);
        }
    }//GEN-LAST:event_btProximoActionPerformed

    private void btUltimoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btUltimoActionPerformed
        int linhaAtual;
        linhaAtual = jTUnidade.getRowCount();
        if (linhaAtual > 0) {
            linhaAtual = jTUnidade.getRowCount() - 1;
            jTUnidade.changeSelection(linhaAtual, linhaAtual, false, false);

        }

        btProximo.setEnabled(false);
        btUltimo.setEnabled(false);
        btPrimeiro.setEnabled(true);
        btAnterior.setEnabled(true);
    }//GEN-LAST:event_btUltimoActionPerformed

    private void jTUnidadeMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTUnidadeMouseClicked
        if (opcao.equals("")) {
            int linhaAtual;
            linhaAtual = jTUnidade.getSelectedRow();
            jTUnidade.changeSelection(linhaAtual, linhaAtual, false, false);

        }
    }//GEN-LAST:event_jTUnidadeMouseClicked

    private void jTUnidadeKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTUnidadeKeyReleased
        int linhaAtual;
        linhaAtual = jTUnidade.getSelectedRow();
        jTUnidade.changeSelection(linhaAtual, linhaAtual, false, false);

    }//GEN-LAST:event_jTUnidadeKeyReleased

    private void jtCodSetorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtCodSetorActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jtCodSetorActionPerformed

    private void jTnumeroProcessoFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTnumeroProcessoFocusLost
//        if (!jTnumeroProcesso.getText().trim().equals("")) {
//            tabelaCod();
//            monta_jTProcessoCidigo();
//        } else {
//            monta_jTPRocessoGERAL();
//        }
    }//GEN-LAST:event_jTnumeroProcessoFocusLost

    private void jTnumeroProcessoKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTnumeroProcessoKeyReleased
        if (!jTnumeroProcesso.getText().trim().equals("")) {
//             tabelaCod();
            monta_jTProcessoCidigo();
        } else {
            monta_jTPRocessoGERAL();
        }
        //   monta_jTProcessoCidigo();
    }//GEN-LAST:event_jTnumeroProcessoKeyReleased

    private void jTnumeroProcessoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTnumeroProcessoActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTnumeroProcessoActionPerformed

    private void jtAssunto1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtAssunto1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jtAssunto1ActionPerformed

    private void jtAssunto1FocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jtAssunto1FocusLost
        // TODO add your handling code here:
    }//GEN-LAST:event_jtAssunto1FocusLost

    private void jtAssunto1KeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtAssunto1KeyReleased
        if (!jtAssunto1.getText().trim().equals("")) {
//             tabelaCod();
            monta_jTAssunto();
        } else {
            monta_jTPRocessoGERAL();
        }
    }//GEN-LAST:event_jtAssunto1KeyReleased

    private void cbMes2KeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_cbMes2KeyReleased
        if (cbMes2.getSelectedItem() != null) {
//             tabelaCod();
            monta_jTProcessMESANO();
        } else {
            monta_jTPRocessoGERAL();
        }
    }//GEN-LAST:event_cbMes2KeyReleased

    private void jtInteressado1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtInteressado1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jtInteressado1ActionPerformed

    private void jtInteressado1FocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jtInteressado1FocusLost
        // TODO add your handling code here:
    }//GEN-LAST:event_jtInteressado1FocusLost

    private void jtInteressado1KeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtInteressado1KeyReleased
        if (!jtInteressado1.getText().trim().equals("")) {
//             tabelaCod();
            monta_jTProcessInterresse();
        } else {
            monta_jTPRocessoGERAL();
        }
    }//GEN-LAST:event_jtInteressado1KeyReleased

    private void jRNumeroMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jRNumeroMouseClicked
        // TODO add your handling code here:
    }//GEN-LAST:event_jRNumeroMouseClicked

    private void jRNumeroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRNumeroActionPerformed
        exibePainel();
    }//GEN-LAST:event_jRNumeroActionPerformed

    private void jRDataActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRDataActionPerformed
        exibePainel();
    }//GEN-LAST:event_jRDataActionPerformed

    private void jRMesanoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRMesanoActionPerformed
        exibePainel();
    }//GEN-LAST:event_jRMesanoActionPerformed

    private void jRInteressadoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRInteressadoActionPerformed
        exibePainel();
    }//GEN-LAST:event_jRInteressadoActionPerformed

    private void jRAssuntoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRAssuntoActionPerformed
        exibePainel();
    }//GEN-LAST:event_jRAssuntoActionPerformed

    private void jtData1KeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtData1KeyReleased
//        if ((jtData1.getCalendar() != null)) {
//            JOptionPane.showMessageDialog(null, "campo novo tabela especifica");
//            monta_jTData();
//        } else {
//            JOptionPane.showMessageDialog(null, "campo novo tabela geral");
//            monta_jTPRocessoGERAL();
//        }
//        JOptionPane.showMessageDialog(null, "Entrou na validação");
    }//GEN-LAST:event_jtData1KeyReleased

    private void jtData1AncestorAdded(javax.swing.event.AncestorEvent evt) {//GEN-FIRST:event_jtData1AncestorAdded

    }//GEN-LAST:event_jtData1AncestorAdded

    private void jtData1ComponentAdded(java.awt.event.ContainerEvent evt) {//GEN-FIRST:event_jtData1ComponentAdded

    }//GEN-LAST:event_jtData1ComponentAdded

    private void jtData1InputMethodTextChanged(java.awt.event.InputMethodEvent evt) {//GEN-FIRST:event_jtData1InputMethodTextChanged

    }//GEN-LAST:event_jtData1InputMethodTextChanged

    private void jtData1FocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jtData1FocusLost


    }//GEN-LAST:event_jtData1FocusLost

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        try {
            if ((jtData1.getCalendar() != null)) {
                monta_jTData();
            } else {
                monta_jTPRocessoGERAL();
            }
        } catch (Exception e) {

        }

    }//GEN-LAST:event_jButton1ActionPerformed

    private void jTnumeroProcessoKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTnumeroProcessoKeyTyped
        String caracteres = "0987654321-,./";
        if (!caracteres.contains(evt.getKeyChar() + "")) {
            evt.consume();
        }
    }//GEN-LAST:event_jTnumeroProcessoKeyTyped

    private void jTano1KeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTano1KeyReleased
        try {
            if (!jTano1.getText().trim().equals("")) {
//             tabelaCod();
                monta_jTProcessMESANO();
            } else {
                monta_jTPRocessoGERAL();
            }
        } catch (Exception e) {
        }


    }//GEN-LAST:event_jTano1KeyReleased

    private void btSairActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btSairActionPerformed
        saiTela();
    }//GEN-LAST:event_btSairActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btAnterior;
    private javax.swing.JButton btPrimeiro;
    private javax.swing.JButton btProximo;
    private javax.swing.JButton btSair;
    private javax.swing.JButton btUltimo;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.ButtonGroup buttonGroup2;
    private javax.swing.JComboBox cbMes2;
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanelAssunto;
    private javax.swing.JPanel jPanelData;
    private javax.swing.JPanel jPanelInteressado1;
    private javax.swing.JPanel jPanelMesano;
    private javax.swing.JPanel jPanelNumero;
    private javax.swing.JPanel jPanelPadrao;
    private javax.swing.JRadioButton jRAssunto;
    private javax.swing.JRadioButton jRData;
    private javax.swing.JRadioButton jRInteressado;
    private javax.swing.JRadioButton jRMesano;
    private javax.swing.JRadioButton jRNumero;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable jTUnidade;
    private javax.swing.JFormattedTextField jTano1;
    private javax.swing.JTextField jTnumeroProcesso;
    private javax.swing.JTextField jtAssunto1;
    private javax.swing.JTextField jtCodSetor;
    private com.toedter.calendar.JDateChooser jtData1;
    private javax.swing.JTextField jtInteressado1;
    private javax.swing.JLabel lbCodigo;
    private javax.swing.JLabel lbCodigo1;
    private javax.swing.JLabel lbCodigo3;
    private javax.swing.JLabel lbCodigo4;
    private javax.swing.JLabel lbCodigo5;
    // End of variables declaration//GEN-END:variables

    public void saiTela() {
        framePesquisarProcesso.this.dispose();
    }

    public void ajustaCursor(int tipo) {
        Cursor cursor;

        if (tipo == 0) {
            cursor = Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR);
        } else {
            cursor = Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
        }

        setCursor(cursor);

    }

    public void tabelaAssunto() {
        jTUnidade.setModel(modeloAssunto);

        modeloAssunto.addColumn("Código");
        modeloAssunto.addColumn("Data");
        modeloAssunto.addColumn("Interresado");
        modeloAssunto.addColumn("Assunto");

        jTUnidade.getColumnModel().getColumn(0).setPreferredWidth(15);
        jTUnidade.getColumnModel().getColumn(1).setPreferredWidth(20);
        jTUnidade.getColumnModel().getColumn(2).setPreferredWidth(50);
        jTUnidade.getColumnModel().getColumn(3).setPreferredWidth(100);

        //codigo para esconder uma coluna na JTable
        //Esconder alguma coluna: No Caso a Primeira Coluna
//        jTUnidade.getColumnModel().getColumn(0).setMinWidth(0);
//        jTUnidade.getColumnModel().getColumn(0).setPreferredWidth(0);
//        jTUnidade.getColumnModel().getColumn(0).setMaxWidth(0);
    }

    public void tabelaCod() {
        jTUnidade.setModel(modelo);

        modelo.addColumn("Código");
        modelo.addColumn("Data");
        modelo.addColumn("Interresado");
        modelo.addColumn("Assunto");

        jTUnidade.getColumnModel().getColumn(0).setPreferredWidth(15);
        jTUnidade.getColumnModel().getColumn(1).setPreferredWidth(20);
        jTUnidade.getColumnModel().getColumn(2).setPreferredWidth(50);
        jTUnidade.getColumnModel().getColumn(3).setPreferredWidth(100);

        //codigo para esconder uma coluna na JTable
        //Esconder alguma coluna: No Caso a Primeira Coluna
//        jTUnidade.getColumnModel().getColumn(0).setMinWidth(0);
//        jTUnidade.getColumnModel().getColumn(0).setPreferredWidth(0);
//        jTUnidade.getColumnModel().getColumn(0).setMaxWidth(0);
    }

    public void tabelaInterrese() {
        jTUnidade.setModel(modelo);

        modelo.addColumn("Código");
        modelo.addColumn("Data");
        modelo.addColumn("Interresado");
        modelo.addColumn("Assunto");

        jTUnidade.getColumnModel().getColumn(0).setPreferredWidth(15);
        jTUnidade.getColumnModel().getColumn(1).setPreferredWidth(20);
        jTUnidade.getColumnModel().getColumn(2).setPreferredWidth(50);
        jTUnidade.getColumnModel().getColumn(3).setPreferredWidth(100);

        //codigo para esconder uma coluna na JTable
        //Esconder alguma coluna: No Caso a Primeira Coluna
//        jTUnidade.getColumnModel().getColumn(0).setMinWidth(0);
//        jTUnidade.getColumnModel().getColumn(0).setPreferredWidth(0);
//        jTUnidade.getColumnModel().getColumn(0).setMaxWidth(0);
    }

    public void tabelaGERAL() {
        jTUnidade.setModel(modelo);

        modelo.addColumn("Código");
        modelo.addColumn("Data");
        modelo.addColumn("Interresado");
        modelo.addColumn("Assunto");

        jTUnidade.getColumnModel().getColumn(0).setPreferredWidth(10);
        jTUnidade.getColumnModel().getColumn(1).setPreferredWidth(20);
        jTUnidade.getColumnModel().getColumn(2).setPreferredWidth(50);
        jTUnidade.getColumnModel().getColumn(3).setPreferredWidth(100);

        //codigo para esconder uma coluna na JTable
        //Esconder alguma coluna: No Caso a Primeira Coluna
//        jTUnidade.getColumnModel().getColumn(0).setMinWidth(0);
//        jTUnidade.getColumnModel().getColumn(0).setPreferredWidth(0);
//        jTUnidade.getColumnModel().getColumn(0).setMaxWidth(0);
    }
//MONTAPRINCIPAL

    private void monta_jTPRocessoGERAL() {

        ProcessoDAO udao = new ProcessoDAO();

        ArrayList<Processo> lista = new ArrayList<Processo>();

        modelo.setNumRows(0);
        lista = udao.findAll2();
        SimpleDateFormat dataFormatada = new SimpleDateFormat("dd/MM/yyyy");
        for (int i = 0; i < lista.size(); i++) {
            modelo.addRow(new Object[]{lista.get(i).getId_Processo(),
                dataFormatada.format(lista.get(i).getData().getTime()),
                lista.get(i).getInteressado(),
                lista.get(i).getAssunto(),});
        }

    }
    //MONTATABELAASSUNTO

    private void monta_jTAssunto() {
//      Fachada f = new Fachada();
        //MontaAssunto
        ProcessoDAO udao = new ProcessoDAO();
        Processo p = new Processo();

        List<Processo> lista = new ArrayList<Processo>();
        modelo.setNumRows(0);
        lista = udao.pesquisarProcessoAssunto(jtAssunto1.getText());
        SimpleDateFormat dataFormatada = new SimpleDateFormat("dd/MM/yyyy");
        for (int i = 0; i < lista.size(); i++) {
            modelo.addRow(new Object[]{lista.get(i).getId_Processo(),
                dataFormatada.format(lista.get(i).getData().getTime()),
                lista.get(i).getInteressado(),
                lista.get(i).getAssunto(),});
        }
    }

    //MontaTABELACODIGO
    private void monta_jTProcessoCidigo() {
        ProcessoDAO pdao = new ProcessoDAO();
        List<Processo> lista;

        modelo.setNumRows(0);
        lista = pdao.pesquisaProcesso(Integer.parseInt(jTnumeroProcesso.getText().toString()));

        SimpleDateFormat dataFormatada = new SimpleDateFormat("dd/MM/yyyy");
        for (int i = 0; i < lista.size(); i++) {
            modelo.addRow(new Object[]{lista.get(i).getId_Processo(),
                dataFormatada.format(lista.get(i).getData().getTime()),
                lista.get(i).getInteressado(),
                lista.get(i).getAssunto()
            });
        }
    }
//MONTAINTERESSE

    private void monta_jTProcessInterresse() {
        ProcessoDAO pdao = new ProcessoDAO();
        List<Processo> lista;
        SimpleDateFormat dataFormatada = new SimpleDateFormat("dd/MM/yyyy");
        modelo.setNumRows(0);
        lista = pdao.pesquisaProcessoInterrese(jtInteressado1.getText());
        for (int i = 0; i < lista.size(); i++) {
            modelo.addRow(new Object[]{lista.get(i).getId_Processo(),
                dataFormatada.format(lista.get(i).getData().getTime()),
                lista.get(i).getInteressado(),
                lista.get(i).getAssunto()
            });
        }
    }

    private void monta_jTData() {
        ProcessoDAO pdao = new ProcessoDAO();
        List<Processo> lista;
        SimpleDateFormat dataFormatada = new SimpleDateFormat("dd/MM/yyyy");
        modelo.setNumRows(0);

//        String dtFinal1 = jtData1.getDateFormatString();
//        String[] aFinal1 = dtFinal1.split("/");  
//        java.util.Calendar dtF1 = new GregorianCalendar(TimeZone.getTimeZone("GMT-3"), new Locale("pt_BR"));
//        dtF1.set(java.util.Calendar.YEAR, Integer.parseInt(aFinal1[2]));//aqui seta o ano  
//        dtF1.set(java.util.Calendar.MONTH, Integer.parseInt(aFinal1[1]) - 1);//aqui seta o mes  
//        dtF1.set(java.util.Calendar.DATE, Integer.parseInt(aFinal1[0]));//aqui seta o dia  
        lista = pdao.pesquisaProcessoData(jtData1.getCalendar());

        for (int i = 0; i < lista.size(); i++) {
            modelo.addRow(new Object[]{lista.get(i).getId_Processo(),
                dataFormatada.format(lista.get(i).getData().getTime()),
                lista.get(i).getInteressado(),
                lista.get(i).getAssunto()
            });
        }

    }

    private void monta_jTProcessMESANO() {
        ProcessoDAO pdao = new ProcessoDAO();
        List<Processo> lista;
        SimpleDateFormat dataFormatada = new SimpleDateFormat("dd/MM/yyyy");
        modelo.setNumRows(0);

        lista = pdao.pesquisaProcessoMESANO(cbMes2.getSelectedItem().toString(), Integer.parseInt(jTano1.getText()));
        for (int i = 0; i < lista.size(); i++) {
            modelo.addRow(new Object[]{lista.get(i).getId_Processo(),
                dataFormatada.format(lista.get(i).getData().getTime()),
                lista.get(i).getInteressado(),
                lista.get(i).getAssunto()
            });
        }
    }

    public void limpaCampos() {
        jTnumeroProcesso.setText("");
        jtData1.setCalendar(null);
        cbMes2.setSelectedIndex(0);
        jTano1.setText("");
        jtInteressado1.setText("");
        jtAssunto1.setText("");
    }

    public void exibePainel() {
        jPanelPadrao.setVisible(false);
        monta_jTPRocessoGERAL();
        limpaCampos();
        if (jRNumero.isSelected()) {
            jPanelNumero.setVisible(true);
            jPanelData.setVisible(false);
            jPanelAssunto.setVisible(false);
            jPanelMesano.setVisible(false);
            jPanelInteressado1.setVisible(false);
        } else if (jRData.isSelected()) {

            jPanelNumero.setVisible(false);
            jPanelData.setVisible(true);
            jPanelAssunto.setVisible(false);
            jPanelMesano.setVisible(false);
            jPanelInteressado1.setVisible(false);
        } else if (jRMesano.isSelected()) {

            jPanelNumero.setVisible(false);
            jPanelData.setVisible(false);
            jPanelAssunto.setVisible(false);
            jPanelMesano.setVisible(true);
            jPanelInteressado1.setVisible(false);
        } else if (jRInteressado.isSelected()) {

            jPanelInteressado1.setVisible(true);
            jPanelNumero.setVisible(false);
            jPanelData.setVisible(false);
            jPanelAssunto.setVisible(false);
            jPanelMesano.setVisible(false);

        } else if (jRAssunto.isSelected()) {

            jPanelNumero.setVisible(false);
            jPanelData.setVisible(false);
            jPanelAssunto.setVisible(true);
            jPanelMesano.setVisible(false);
            jPanelInteressado1.setVisible(false);
        }
    }

}
